[#import "/framework/JGP.htm"  as JGP]
<!--
项目   jgp-cloud-parent
作者   LOUFEI [Gavin]
时间   2018/12/4
-->
[@JGP.head "工单查询"]
    <style>
        .no-applied .jgp-btn{
            border-color: #9a9a9a !important;
            background: -webkit-gradient(linear, left top, left bottom, from(rgba(228, 228, 228, 0.25)), to(#9a9a9a))!important;
            background: linear-gradient(rgba(228, 228, 228, 0.25)), to(#9a9a9a))!important;
            cursor:not-allowed;
        }

        .is-important{
            background-color: red;
            color: white;
        }

        .applied .jgp-btn{
            border-color: #f0881d !important;
            background: -webkit-gradient(linear, left top, left bottom, from(rgba(27, 159, 255, 0.64)), to(#1B9AF7))!important;
            background: linear-gradient(rgba(27, 159, 255, 0.64)), to(#1B9AF7))!important;
        }
        .over .jgp-btn{
            border-color: #f0881d !important;
            background: #6dff28 !important;
            cursor:not-allowed;
        }
    </style>
[/@JGP.head]
[@JGP.body]
     <jgp-div _row="['150','*']" _runit="px">
         <jgp-query slot="1-1" _auto="false" _id="queryForm" _target="processGrid" _action="/workflow/processApiController/queryProcess">
             <jgp-form-group _title="搜索条件">
                 <jgp-text _name="name" _label="工单名称" _col="3"></jgp-text>
                 <jgp-text _name="sn" _label="工单号" _col="3"></jgp-text>
                 <jgp-drop _name="category" _label="工单类型" _col="3" _url="/workflow/editorApiController/dropCategory"></jgp-drop>
                 <jgp-drop _name="status" _label="工单状态" _col="3"
                           _list="[{'label':'进行中','value':'1'},
                            {'label':'结束','value':'2'},
                            {'label':'作废','value':'3'}]"></jgp-drop>
             </jgp-form-group>
             <jgp-form-group>
                 <jgp-date-time _name="applyTimeBegin" _format="date" _label="提交时间" _col="3"></jgp-date-time>
                 <jgp-date-time _name="applyTimeOver" _format="date" _col="2"></jgp-date-time>
                 <jgp-date-time _name="endTimeBegin" _format="date" _label="完成时间" _col="3"></jgp-date-time>
                 <jgp-date-time _name="endTimeOver" _format="date" _col="2"></jgp-date-time>
             </jgp-form-group>
             <jgp-form-group>
                 <jgp-radio _name="groupType" _value="1" _list="[{'label':'我发起的','value':'1'},
                {'label':'我审批的','value':'2'},
                {'label':'我的部门审批的','value':'3'}]"></jgp-radio>
                 <jgp-hidden _name="userId" _value="${userId!''}"></jgp-hidden>
                 <jgp-btn _margin="15px 0px" _fn="queryFn">查询</jgp-btn>
                 <jgp-btn _margin="15px 0px" _fn="resetFn">重置</jgp-btn>
             </jgp-form-group>
         </jgp-query>
         <jgp-grid _cols="['*','*','*','*','*']" _id="processGrid" slot="2-1"
                   _record_tools="[{'icon':'edit','tip':'查看','fn':'taskHandlerDialog'},{'icon':'edit','tip':'查看流程图','fn':'showProcessPic'}]">

             <jgp-grid-col _name="applyNode"
                           _filter_render="filterRenderFn"
                           _fns="['passProc']
                           _wrap="<jgp-btn>[content]</jgp-btn>"
                           _transform_value="transformApplyStateFn" ></jgp-grid-col>
         </jgp-grid>
     </jgp-div>
[/@JGP.body]

[@JGP.foot]
    <script>

        function queryFn() {
            JGP.query('queryForm').search();
        }

        function resetFn() {
            JGP.query('queryForm').reset();
        }

        function showProcessPic(data) {
            var procId = data.back.record.id;
            var config = {
                url: '/workflow/processController/showProcessPic/' + procId,
                onLoaded:function (dialog) {
                    dialog.toggleMax();
                }
            };
            JGP.$dialog(config);
        }

        function submit(data) {
            var procId = data.back.record.id;
            var userId = '${userId!''}';
            new JGP.Task().submit(userId,procId);
        }


        function transformApplyStateFn(args) {
            if(args.back.value){
                return '未传递'
            }else if(args.back.record.completeTime){
                return '完成'
            }else{
                return '进行中'
            }
        }

        function filterRenderFn(data){
            var value = data.back.value;
            return data.back.record.completeTime?'over':(value?'applied':'no-applied');
        }

        function passProc(args) {
            if(args.back.value){
                var busiFormConfig = {
                    procId:args.back.record.id,
                    editFlag:true
                };
                var dialogConfig = {
                    title:'任务处理',
                    width:'900px',
                    callback:function(){
                        queryFn()
                    }
                };
                new JGP.Task().taskHandlerDialog(busiFormConfig,dialogConfig);
            }
        }

        function taskHandlerDialog(data) {
            var config = {
                url:"/workflow/processController/showProcFlowed?procId="+data.back.record.id,
                title:'工单:'+data.back.record.sn,
                width:'900px'
            };
            JGP.$dialog(config);
        }
    </script>
[/@JGP.foot]